package com.tueye.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tueye.base.util.BaseDao;
import com.tueye.base.util.IBaseHbnDao;
import com.tueye.base.util.Page;
import com.tueye.dao.IKeyWordDao;
import com.tueye.entity.KeyWords;

@Scope("prototype")
@Component("keyWordDao")
public class KeyWordDaoImpl extends BaseDao implements IKeyWordDao {

	@Autowired
	@Qualifier("baseHbnDao")
	private IBaseHbnDao baseHbnDao;

	@Override
	public void addKeyWord(KeyWords keyWord) {

		baseHbnDao.saveOrUpdate(keyWord);
	}

	@Override
	public void delKeyWords(String id) {
		KeyWords keyWord = (KeyWords) baseHbnDao.findById(KeyWords.class, id);
		baseHbnDao.delete(keyWord);
	}

	@Override
	public KeyWords getKeyWordsById(String id) {

		return (KeyWords) baseHbnDao.findById(KeyWords.class, id);
	}

	@Override
	public Page pagedQueryByHQL(String hql, int pageNo, int pageSize,
			Object... values) {

		return baseHbnDao.pagedQueryByHQL(hql, pageNo, pageSize, values);
	}

	@Override
	public List<KeyWords> getKeyWordList() {
		List<KeyWords> keywordList = new ArrayList<KeyWords>();
		keywordList = this.baseHbnDao.queryList("from KeyWords");
		return keywordList;
	}

}
